<template>
  <div class="demo">
    <template>
      <div v-if="mode === 'edit'">
        <!-- 图片轮播 -->
        <div v-if="currentDataList && currentDataList.length > 0">
          <div style="width: 100%" v-if="swipeAlign=='top'&&swipeAlign!='hide'">
            <div style="text-align: center">{{ swipeStr }}</div>
          </div>
          <el-carousel
            :style="{ height: verticalHeight }"
            :type="swipeType"
            :direction="verticalVal"
          >
          <el-carousel-item v-for="(item, index) in currentDataList" :key="index">
           <a :href="item.link"><img :src="item.imageUrl" alt=""></a>
          </el-carousel-item>
          </el-carousel>
          <div style="width: 100%" v-if="swipeAlign=='bottom'&&swipeAlign!='hide'">
            <div style="text-align: center">{{ swipeStr }}</div>
          </div>
        </div>
      </div>
      <div v-else>{{ value }}</div>
    </template>
  </div>
</template>

<script>
import datasource from "../../mixins/datasource";
export default {
  name: "swipe",
  mixins: [datasource],
  components: {},
  props: {
    mode: {
      default: "edit", // 编辑模式和 edit， 展示模式 view
    },
    readonly: {
      type: Boolean,
      default: false,
    },
    disabled: {
      type: Boolean,
      default: false,
    },
    vertical: {
      type: Boolean,
      default: false,
    },
    verticalHeight: {
      type: String,
      default: "300px",
    },
    swipeType: {
      type: String,
      default: "",
    },
    swipeNo: {
      type: Number,
      default: "",
    },
    swipeAlign: {
      type: String,
      default: "",
    },
    swipeStr:{
      type: String,
      default: "",
    },
    currentDataList:{
      default:[
        { imageUrl: 'https://t7.baidu.com/it/u=2168645659,3174029352&fm=193&f=GIF', link: 'https:www.baidu.com' },
        { imageUrl: 'https://t7.baidu.com/it/u=2621658848,3952322712&fm=193&f=GIF', link: 'https://developer.mozilla.org/zh-CN/' },
        { imageUrl: 'https://t7.baidu.com/it/u=124476473,2583135375&fm=193&f=GIF', link: 'https://gitee.com/' }
      ]
    }
  },
  data() {
  },
  computed: {
    verticalVal() {
      return this.vertical ? "vertical" : "horizontal";
    },
  },
  created() {},
  mounted() {
    console.log(this.swipeNo, "this");
  },
  methods: {},
};
</script>
<style lang="scss" scoped>
.el-carousel__container {
  border: 2px solid red;
}
.demo {
  width: 100%;
  overflow: hidden;
  .el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    margin: 0;
    text-align: center;
  }

  .el-carousel__item img {
    width: 100%;
    height: 100%;
  }

  .el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
  }

  .el-carousel__item:nth-child(2n + 1) {
    background-color: #d3dce6;
  }
}
.el-carousel__container {
  height: auto;
}
</style>
